let path = require('path')

const HtmlWebPackPlugin = require('html-webpack-plugin')

module.exports = {
    mode: 'development',
    entry: './src/main.js',
    output: {
        path: path.join(__dirname,'dist'),
        filename: 'bundle.js'
    },
    plugins: [
        new HtmlWebPackPlugin({
            template: './src/public/index.html'
        })
    ],
    module: {
        rules: [
            {
                test: /\.css$/i,
                use: ['style-loader','css-loader']
            },
            {
                test: /\.less$/i,
                use: ['style-loader','css-loader','less-loader']
            },
            {
                test: /\.(png|jpg|gif|jpeg|bmp)$/i,
                type: 'asset'
            },
            {
                test: /\.(woff|woff2|eot|svg|ttf)$/i,
                type: 'asset/resource'
            },
            {
                test: /\.(woff|woff2|eot|svg|ttf)$/,
                type: 'asset/resource',
                generator: {
                  filename: 'static/[hash:6][ext][query]'
                }
            },
            {
                test: /\.js$/,
                exclude: /(node_modules|bower_components)/,
                use: {
                  loader: 'babel-loader',
                  options: {
                    presets: ['@babel/preset-env']
                    }
                }
            }
        ]
    },
    devServer: {
        port: 3006,
        open: true
    }
}